﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="audit", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Audit))]
    public class AuditSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IAudit clazz;
        
        public AuditSerializer(IAudit clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("casinobday");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Casinobday))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("objid");
            if (clazz.Objid!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Objid))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Objid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("createtime");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.Createtime))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("moditime");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.Moditime))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="casinobday") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>audit>casinobday");
                }
                clazz.Casinobday = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("casinobday")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>audit>casinobday", Reader.LocalName);
            }
            if (Reader.LocalName=="objid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>audit>objid");
                }
                clazz.Objid = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("objid")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>audit>objid", Reader.LocalName);
            }
            if (Reader.LocalName=="createtime") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>audit>createtime");
                }
                clazz.Createtime = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("createtime")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>audit>createtime", Reader.LocalName);
            }
            if (Reader.LocalName=="moditime") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>audit>moditime");
                }
                clazz.Moditime = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("moditime")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>audit>moditime", Reader.LocalName);
            }
        }
    }
}
